package day03.text01;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.TreeMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Service {
    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(9999);



        while (true) {
            Socket accept = serverSocket.accept();
            //创建本地文件
            //使用线程方法
            MyRunbale myRunbale = new MyRunbale(accept);

            new Thread(myRunbale).start();
            //使用线程池
            ThreadPoolExecutor tp = new ThreadPoolExecutor(2,
                    5,
                    2,
                    TimeUnit.SECONDS,
                    new ArrayBlockingQueue<>(10),
                    Executors.defaultThreadFactory(),
                    new ThreadPoolExecutor.AbortPolicy());
            tp.submit(myRunbale);
            tp.shutdown();

        }

    }
}
